/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import DAO.Iter.MonHocDAO;
import TableModel.Monhoc;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;


/**
 *
 * @author vt
 */
public class MonHocDAOImpl extends HibernateDaoSupport implements MonHocDAO {

    @Override
    public List<Monhoc> findAllMonHoc() {
        return getHibernateTemplate().find("from Monhoc");
    }

    @Override
    public void update(Monhoc id) {      
       id.toString();
        getHibernateTemplate().saveOrUpdate(id);
    }

    @Override
    public void add(Monhoc id) {
        getHibernateTemplate().save(id);
    }

    @Override
    public void delete(Monhoc id) {
       getHibernateTemplate().delete(id);
    }

    @Override
    public Monhoc findById(String id) {
      List list = this.getHibernateTemplate().find("from Monhoc monhoc where monhoc.mamh = ?", id);
		if(list.isEmpty()){
			return null;
		}
		return (Monhoc) list.get(0);

    }
}
